﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Restful.Net.Tests.TestDomain;

namespace Restful.Net.TestHost
{
    public class GroupService
    {
        DomainObjectDatabase db = new DomainObjectDatabase();

        [RestMethod(Verb = HttpVerb.Get, UriTemplate = "")]
        public List<Uri> GetGroups(string ownerID)
        {
            return db.GetAllContacts(ownerID)
                .SelectMany(co => co.Groups).Distinct()
                .Select(g => new Uri("http://localhost:8080/addressbook/" + ownerID + "/contacts?groupID=" + g))
                .ToList();

        }
    }
}